package com.fenqing.leetcode.code.sword_refers_offer_ii;

import com.fenqing.annotations.Execute;
import com.fenqing.bean.TreeNode;
import com.fenqing.core.Topic;

public class Topic054 extends Topic {

    private int sum;

    @Execute
    public TreeNode convertBST(TreeNode root) {
        if (root != null) {
            convertBST(root.right);
            sum += root.val;
            root.val = sum;
            convertBST(root.left);
        }
        return root;
    }


    public static void main(String[] args) {
        TreeNode treeNode = new Topic054().run("[4,1,6,0,2,5,7,null,null,null,3,null,null,null,8]");
        System.out.println(treeNode);
    }
}
